package com.softsec.isc.analysis;
import java.io.DataInputStream;
import java.io.IOException;

public class GetDexTypeId {
	
	
	public static void TypeId(String fileName) throws IOException{
		
		int flag=GetFinal.getFlag(fileName);
		DataInputStream input=apkExtractor.getDexDataInputStreamWithBuffered(fileName);
		
		int offset=DexMapItemMapper.getInstance().getDexMapItemOffset("kDexTypeTypeIdItem");
		int count=DexMapItemMapper.getInstance().getDexMapItemCount("kDexTypeTypeIdItem");
		byte[] bufferArray = new byte[4];
		
		input.skip(offset);	     
		String TypeStr="";
		for(int i =0;i<count;i++){	    	 
			input.read(bufferArray);
			int TypeOffset=GetFinal.GetSixteen(bufferArray, flag);
			TypeStr=DexMapItemMapper.getInstance().getDexString(TypeOffset);
			DexMapItemMapper.getInstance().addDexTypeId(i, TypeStr);
			
		}
		
//		for (int index : DexMapItemMapper.getInstance().getDexTypeIdMap().keySet()) {
//			System.out.println("TypeId"+index + " : " + DexMapItemMapper.getInstance().getDexType(index));
//		}   
	}
}
